<?php

namespace common\logics\trade\scope;

use Yii;

/**
 * 商城业务订单
 *
 * @author emhome <emhome@163.com>
 * @since 2.0
 */
class CompatibleScopeShopOrder extends \common\models\shop\ShopOrderUnified implements CompatibleScopeInterface {

    /**
     * 商城统一订单号
     * @return string
     */
    public function getOrderNo() {
        return $this->order_no;
    }

    /**
     * 通过商城统一订单号获取统一订单模型
     * @return static
     */
    public static function findByBizno($bizno) {
        $query = static::find()->andWhere([
            'order_no' => $bizno
        ]);
        $query->debug();
        return $query->one();
    }

    public function getUserId() {
        return $this->user_id;
    }

    public function getIsExpired() {
        $allowStatus = [
            static::STATUS_DEFAULT,
            static::STATUS_ACTIVE,
        ];
        if (in_array($this->status, $allowStatus) && $this->countdown > 0) {
            return false;
        }
        return true;
    }

}
